/* tcptimewait.c - tcptimewait */

#include "tcb.h"
#include "tcp.h"

/*------------------------------------------------------------------------
 *  tcptimewait -  do TIME_WAIT state input processing
 *------------------------------------------------------------------------
 */
int tcptimewait(struct tcb *ptcb, struct udp *pudp)
{
	//struct	ip	*pip = (struct ip *)pep->ep_data;
	struct	tcp	*ptcp = (struct tcp*)(pudp->udp_data);

	if (ptcp->tcp_code & TCPF_RST)
		return tcbdealloc(ptcb);
	if (ptcp->tcp_code & TCPF_SYN) {
		tcpreset(pudp);
		return tcbdealloc(ptcb);
	}
	tcpacked(ptcb, pudp);
	tcpdata(ptcb, pudp);		/* just ACK any packets */
	tcpwait(ptcb);
	return OK;
}
